<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Overtrue\LaravelFollow\Traits\CanBeLiked;

class Comment extends Model
{

    use CanBeLiked;

    use SoftDeletes;

    protected $fillable = [
        'user_id','check_id','liked','commentd','body','rank','reply_id',
    ];

    

    public function reports() //这个帖子的举报记录
    {
        return $this->morphMany(Report::class, 'reportable');
    }
    

    // 被评论的帖子
    public function post()
    {
        return $this->belongsTo(Post::class);
    }

    // 发表评论的用户
    public function user()
    {
        return $this->belongsTo(\App\User::class);
    }

    public function replies() //这个评论的回复
    {
         return $this->hasMany(Comment::class,'reply_id', 'id');
    }
    
    public function quote()  //这个评论是评论谁的评论的 引用谁的评论
    {
         return $this->belongsTo(Comment::class,'reply_id', 'id');
    }

}
